'''
从前往后逐位比较，如果有不相等的直接返回前缀之前的即可
'''
class Solution:
    def longestCommonPrefix(self , strs ):
        # write code here
        if len(strs) == 0:
            return ''
        if len(strs) == 1:
            return strs[0]
        a = min(strs)
        b = max(strs)
        for i in range(len(a)):
            if a[i] != b[i]:
                return a[:i]
        return a